﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace QFramework
{
    [System.Serializable]
    public class StateControl : MonoBehaviour
    {
        [SerializeField]
        private string                          m_FsmName="Fsm";
        [SerializeField]
        private string                          m_Description="Description...";
        [SerializeField]
        private bool                            m_ResetEnable=true;
        [SerializeField]
        private FSM                             m_Fsm;

        private void Awake()
        {
            
        }

        private void Start()
        {
            m_Fsm.Start();
        }

        private void OnEnable()
        {
            if (m_ResetEnable && m_Fsm!=null)
            {
                m_Fsm.Exit();
            }
        }

        private void Update()
        {
            if (m_Fsm!=null)
            {
                m_Fsm.OnUpdate();
            }
        }

        public void Event(string m_Event)
        {
            if (m_Fsm != null)
            {
                m_Fsm.Event(m_Event);
            }
        }
    }
}